home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- BackColor = &H00C0C0C0&
- Caption = "Ping!!"
- ClientHeight = 5010
- ClientLeft = 1200
- ClientTop = 1500
- ClientWidth = 5745
- Height = 5415
- Left = 1140
- LinkTopic = "Form1"
- ScaleHeight = 5010
- ScaleWidth = 5745
- Top = 1155
- Width = 5865
- Begin CommandButton Command1
- Caption = "Ping !!"
- Height = 375
- Left = 4440
- TabIndex = 5
- Top = 240
- Width = 1215
- End
- Begin TextBox tResponse
- Height = 4095
- Left = 120
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 3
- Top = 840
- Width = 5535
- End
- Begin TextBox tHostAddress
- Height = 285
- Left = 1440
- TabIndex = 2
- Top = 480
- Width = 2895
- End
- Begin TextBox tHostName
- Height = 285
- Left = 1440
- TabIndex = 1
- Top = 120
- Width = 2895
- End
- Begin IPPORT IPPort1
- EOL = ""
- InBufferSize = 2048
- Left = 480
- LocalPort = 0
- OutBufferSize = 2048
- Port = 0
- Top = 0
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Host Address:"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 4
- Top = 480
- Width = 2175
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Host Name:"
- Height = 255
- Index = 0
- Left = 120
- TabIndex = 0
- Top = 150
- Width = 1815
- End
- Sub Command1_Click ()
- On Error GoTo ErrorHandling:
- If Command1.Caption = "Stop!" Then
- IPPort1.Connected = False
- MousePointer = 0
- Command1.Caption = "Ping!!"
- Exit Sub
- End If
- IPPort1.EOL = Chr$(10)
- Me.MousePointer = 11
- 'close old connection - if any
- IPPort1.Connected = False
- If IPPort1.HostAddress = "0.0.0.0" Then
- If tHostName <> "" Then
- IPPort1.HostName = tHostName.Text
- tHostAddress.Text = IPPort1.HostAddress
- ElseIf IPPort1.HostAddress <> "" Then
- IPPort1.HostAddress = tHostAddress.Text
- tHostName.Text = IPPort1.HostName
- Else
- MsgBox "Please specify a host."
- Exit Sub
- End If
- End If
- IPPort1.Port = 7 'echo service
- 'ask for connection
- IPPort1.Connected = True
- 'wait until it is achieved
- Do Until IPPort1.Connected: DoEvents: Loop
- 'send data until disconnected
- msg$ = "Hello Hello"
- Command1.Caption = "Stop!"
- Do Until Not IPPort1.Connected
- IPPort1.DataToSend = msg$
- tResponse.SelStart = Len(tResponse.Text)
- tResponse.SelText = "Sent " & Len(msg$) & " bytes: " & msg$ & "... "
- 'now wait a little
- For i = 1 To 10000: DoEvents: Next i
- Exit Sub
- ErrorHandling:
- Me.MousePointer = 0
- MsgBox "Error!! " & Error$
- IPPort1.Connected = False
- Exit Sub
- End Sub
- Sub Form_Resize ()
- margin = tResponse.Left
- tResponse.Height = ScaleHeight - tResponse.Top - margin
- tResponse.Width = ScaleWidth - 2 * margin
- Command1.Left = ScaleWidth - Command1.Width - margin
- tHostName.Width = ScaleWidth - tHostName.Left - Command1.Width - 2 * margin
- tHostAddress.Width = ScaleWidth - tHostAddress.Left - Command1.Width - 2 * margin
- End Sub
- Sub IPPort1_Connected (StatusCode As Integer, Description As String)
- tResponse = ""
- If Description <> "OK" Then
- MsgBox "Connection error: " & Description
- Me.MousePointer = 0
- End If
- End Sub
- Sub IPPort1_DataIn (Text As String, EOL As Integer)
- tResponse.SelStart = Len(tResponse.Text)
- tResponse.SelText = "received " & Len(Text) & " bytes: " & Text & Chr$(13) & Chr$(10)
- End Sub
- Sub IPPort1_Disconnected (StatusCode As Integer, Description As String)
- Me.MousePointer = 0
- If Description <> "OK" Then
- MsgBox "Connection broken: " & Description
- End If
- End Sub
- Sub tHostAddress_KeyPress (KeyAscii As Integer)
- On Error GoTo DAR_Failed:
- If KeyAscii = 13 Then
- KeyAscii = 0
- IPPort1.HostAddress = tHostAddress.Text
- tHostName.Text = IPPort1.HostName
- End If
- Exit Sub
- DAR_Failed:
- MsgBox Error$
- Exit Sub
- End Sub
- Sub tHostName_KeyPress (KeyAscii As Integer)
- On Error GoTo DNR_Failed:
- If KeyAscii = 13 Then
- KeyAscii = 0
- IPPort1.HostName = tHostName.Text
- tHostAddress.Text = IPPort1.HostAddress
- End If
- Exit Sub
- DNR_Failed:
- MsgBox Error$
- Exit Sub
- End Sub
-